import { Button } from 'antd';
import { useState, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { decrement, increment, incrementByAmount } from '../../store/counterSlice';
const Home = () => {
    const count = useSelector(state => state.counter.value)
    const dispatch = useDispatch();
    const [ num, setNum ] = useState(1)
    useEffect(() => {
        console.log(count, num,33)
    }, [count, num])
    const testData = () => {
        setNum(num + 1)
    }
  return (
    <div className="Home">
        <Button   onClick={() => dispatch(increment())}>add</Button>
        <Button  onClick={() => dispatch(decrement())}>increment</Button>
        <Button  onClick={() => dispatch(incrementByAmount(4))}>increment</Button>
        <br/>
        <Button onClick={testData}>testCount</Button>
        <span>{ count }</span>
        <div>{num}</div>
    </div>
  );
}

export default Home;
